package com.hyopt.modules.app.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hyopt.common.utils.R;
import com.hyopt.modules.app.entity.SysDictionaryEntity;
import com.hyopt.modules.app.service.SysDictionaryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author ：Li9527
 * @date ：Created in 2020-01-08 10:29
 * @description：${description}
 * @modified By：
 * @version: 1.0.0
 */
@RestController
@RequestMapping("/app/dictinary")
@Api(value = "AppDictionaryController", tags = {"字典相关业务"})
public class AppDictionaryController {

    @Autowired
    SysDictionaryService sysDictionaryService;

    /**
     * 获取报警等级字典
     * @return
     */
    @GetMapping("/getAlarmLevelList")
    @ApiOperation("获取报警等级字典")
    public R AlarmLevel(HttpServletRequest request) {
        List<SysDictionaryEntity> result = sysDictionaryService.list(
                new QueryWrapper<SysDictionaryEntity>().eq("Keywords","alarm_level"));
        return R.ok().put("data",result);
    }

    /**
     * 获取报警类型字典
     * @return
     */
    @GetMapping("getAlarmTypeList")
    @ApiOperation("获取报警类型字典")
    public R AlarmCode(){
        List<SysDictionaryEntity> result = sysDictionaryService.list(
                new QueryWrapper<SysDictionaryEntity>().eq("Keywords","alarm_type"));
        return R.ok().put("data",result);
    }

    /**
     * 获取处理类型字典
     * @return
     */
    @GetMapping("getDealTypeList")
    @ApiOperation("获取处理类型字典")
    public R OperateResult(){
        List<SysDictionaryEntity> result = sysDictionaryService.list(
                new QueryWrapper<SysDictionaryEntity>().eq("Keywords","alarm_operate_type"));
        return R.ok().put("data",result);
    }

  /**
   * 获取报警状态字典
   * @return
   */
  @GetMapping("/getAlarmStatusList")
  @ApiOperation("获取报警状态字典")
  public R getAlarmStatus(HttpServletRequest request) {
    List<SysDictionaryEntity> result = sysDictionaryService.list(
      new QueryWrapper<SysDictionaryEntity>().eq("Keywords","alarm_status"));
    return R.ok().put("data",result);
  }

}
